package com.swt.gap.service.impl;

import com.swt.gap.dao.FileClassDao;
import com.swt.gap.model.entity.FileClass;
import com.swt.gap.service.DataResourceClassService;
import com.swt.gap.service.SysGroupService;
import com.swt.gap.util.UserLoginUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataResourceClassServiceImpl implements DataResourceClassService {

    private final FileClassDao fileClassDao;
    private final SysGroupService sysGroupService;
    public DataResourceClassServiceImpl(FileClassDao fileClassDao, SysGroupService sysGroupService) {
        this.fileClassDao = fileClassDao;
        this.sysGroupService = sysGroupService;
    }

    @Override
    public List<FileClass> listDataResourceClass(String keyword) {
        Integer userId = UserLoginUtils.getUserId();
        List<Integer> userIds = sysGroupService.listSameGroupUserByUserId(userId);
        return fileClassDao.listByUser(userIds, keyword);
    }
}
